/*
 * JVM_Class.h
 *
 *  Created on: 10.12.2010
 *      Author: Tavin
 */
/*
#include "JVM_ConstantPool.h"
#include "JVM_Field.h"
#include "JVM_Method.h"
#include "JVM_Object.h"
#include "JVM_Interface.h"
#include "JVM_Attribute.h"
*/
#ifndef JVM_CLASS_H_
#define JVM_CLASS_H_

#include "JVM_CP_Table.h"
#include "JVM_CP_Field.h"
#include "JVM_FieldTable.h"
#include "JVM_Field.h"
#include "JVM_MethodTable.h"
#include "JVM_Method.h"
#include "JVM_Exception_Handler_Table.h"





/*
	size=ADRESS_WIDTH; // constant pool table address
	size+=ADRESS_WIDTH; // Field table address
	size+=ADRESS_WIDTH; // Method table address

	size+=SHORT_WIDTH; // Static data size
	size+=SHORT_WIDTH; // Dynamic data size

*/
typedef struct{

	JVM_CP_Table_t *constantPoolTable;
	JVM_FieldTable_t *fieldPoolTable;
	JVM_Method_Table_t *methodPoolTable;
	//JVM_Exception_Handler_Table_t* exceptionHandlerTable; // TODO: NEW

	uint16_t staticDataSize;
	uint16_t instanceDataSize;
	uint16_t staticDataHandle;
	uint16_t dummy;

	//StaticDataSize;
	//DynamicDataSize
}JVM_Class_t;



/****************************************************************************************/
/*																						*/
/*	Function : JVM_Class_getStaticDataSize					Author : OG					*/
/*																						*/
/*	Description : 								   										*/
/*																						*/
/*	Version : 1.0					Date :2011.1.2			Status : Working   			*/
/*																						*/
/****************************************************************************************/

uint16_t static inline JVM_Class_getStaticDataSize(JVM_Class_t * myClass)
{
	return(myClass->staticDataSize);
}


/****************************************************************************************/
/*																						*/
/*	Function : JVM_Class_getStaticDataSize					Author : OG					*/
/*																						*/
/*	Description : 								   										*/
/*																						*/
/*	Version : 1.0					Date :2011.1.2			Status : Working   			*/
/*																						*/
/****************************************************************************************/

uint16_t static inline JVM_Class_getInstanceDataSize(JVM_Class_t * myClass)
{
	return(myClass->instanceDataSize);
}



/****************************************************************************************/
/*																						*/
/*	Function : JVM_Class_getStaticDataHandle				Author : OG					*/
/*																						*/
/*	Description : 								   										*/
/*																						*/
/*	Version : 1.0					Date :2011.1.2			Status : Working   			*/
/*																						*/
/****************************************************************************************/

uint16_t static inline JVM_Class_getStaticDataHandle(JVM_Class_t * myClass)
{
	return(myClass->staticDataHandle);
}



/****************************************************************************************/
/*																						*/
/*	Function : JVM_Class_getFieldCount					Author : OG					*/
/*																						*/
/*	Description : 								   										*/
/*																						*/
/*	Version : 1.0					Date :2011.1.2			Status : Working   			*/
/*																						*/
/****************************************************************************************/

uint16_t static inline JVM_Class_getFieldCount(JVM_Class_t * myClass)
{
	return(myClass->fieldPoolTable->size);

}



/****************************************************************************************/
/*																						*/
/*	Function : JVM_Class_getFieldConstantValueReference		Author : OG					*/
/*																						*/
/*	Description : 								   										*/
/*																						*/
/*	Version : 1.0					Date :2011.1.2			Status : Working   			*/
/*																						*/
/****************************************************************************************/

uint16_t static inline JVM_Class_getFieldConstantValueReference(JVM_Class_t * myClass,uint16_t fieldNumber)
{
	return(myClass->fieldPoolTable->fields[fieldNumber]->constantValueReference);
}



/****************************************************************************************/
/*																						*/
/*	Function : JVM_Class_getFieldType						Author : OG					*/
/*																						*/
/*	Description : 								   										*/
/*																						*/
/*	Version : 1.0					Date :2011.1.2			Status : Working   			*/
/*																						*/
/****************************************************************************************/

uint8_t static inline JVM_Class_getFieldType(JVM_Class_t * myClass,uint16_t fieldNumber)
{
	return(myClass->fieldPoolTable->fields[fieldNumber]->fieldType);
}

/****************************************************************************************/
/*																						*/
/*	Function : JVM_Class_getFieldType						Author : OG					*/
/*																						*/
/*	Description : 								   										*/
/*																						*/
/*	Version : 1.0					Date :2011.1.2			Status : Working   			*/
/*																						*/
/****************************************************************************************/

uint16_t static inline JVM_Class_getFieldDataOffset(JVM_Class_t * myClass,uint16_t fieldNumber)
{
	return(myClass->fieldPoolTable->fields[fieldNumber]->dataOffset);
}


/****************************************************************************************/
/*																						*/
/*	Function : JVM_Class_getCpSize							Author : OG					*/
/*																						*/
/*	Description : 								   										*/
/*																						*/
/*	Version : 1.0					Date :2011.1.3			Status : Working   			*/
/*																						*/
/****************************************************************************************/

uint16_t static inline JVM_Class_getCpSize(JVM_Class_t * myClass)
{
	return(myClass->constantPoolTable->size);
}




/****************************************************************************************/
/*																						*/
/*	Function : JVM_Class_getMethod							Author : OG					*/
/*																						*/
/*	Description : 								   										*/
/*																						*/
/*	Version : 1.0					Date :2011.1.3			Status : Working   			*/
/*																						*/
/****************************************************************************************/

JVM_Method_t  static inline * JVM_Class_getMethod(JVM_Class_t *myClass,uint16_t index)
{
	return(myClass->methodPoolTable->methods[index]);
}

/****************************************************************************************/
/*																						*/
/*	Function : JVM_Class_getMethodCount							Author : OG					*/
/*																						*/
/*	Description : 								   										*/
/*																						*/
/*	Version : 1.0					Date :2011.1.3			Status : Working   			*/
/*																						*/
/****************************************************************************************/

uint16_t  static inline  JVM_Class_getMethodCount(JVM_Class_t *myClass)
{
	return(myClass->methodPoolTable->size);
}

JVM_CP_Integer_t *JVM_Class_getInteger(JVM_Class_t *myClass, uint16_t index);
JVM_CP_Long_t *JVM_Class_getLong(JVM_Class_t *myClass, uint16_t index);
JVM_CP_Float_t *JVM_Class_getFloat(JVM_Class_t *myClass, uint16_t index);
JVM_CP_Double_t *JVM_Class_getDouble(JVM_Class_t *myClass, uint16_t index);


uint16_t JVM_Class_InitFields(JVM_Class_t *myClass);
#endif /* JVM_CLASS_H_ */




